#include "buttongroup.h"
#include "ui_buttongroup.h"

ButtonGroup::ButtonGroup(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::ButtonGroup)
{
    ui->setupUi(this);
}

ButtonGroup::~ButtonGroup()
{
    delete ui;
}

void ButtonGroup::Init_Buttons()
{
    //开始游戏
    ui->start_button_->Set_Image(":/images/start-1.png",":/images/start-3.png",":/images/start-2.png");

    //出牌
    ui->play_card_button_->Set_Image(":/images/chupai_btn-1.png",":/images/chupai_btn-3.png",":/images/chupai_btn-2.png");

    //不要/出牌
    ui->pass_button_->Set_Image(":/images/pass_btn-1.png",":/images/pass_btn-3.png",":/images/pass_btn-2.png");
    ui->play_card_button_1->Set_Image(":/images/chupai_btn-1.png",":/images/chupai_btn-3.png",":/images/chupai_btn-2.png");

    //不抢/1分/2分/3分
    ui->one_score_button_->Set_Image(":/images/1fen-1.png",":/images/1fen-3.png",":/images/1fen-2.png");
    ui->two_scores_button_->Set_Image(":/images/2fen-1.png",":/images/2fen-3.png",":/images/2fen-2.png");
    ui->three_scores_button_->Set_Image(":/images/3fen-1.png",":/images/3fen-3.png",":/images/3fen-2.png");

    QVector<MyPushButton*> btns;
    btns << ui->start_button_ << ui->play_card_button_ << ui->pass_button_ << ui->play_card_button_1 << ui->one_score_button_
         << ui->two_scores_button_ << ui->three_scores_button_;

    for(int i = 0; i < btns.size(); ++i)
    {
        btns[i]->setFixedSize(90,45);
    }

    connect(ui->start_button_, &MyPushButton::clicked, this, &ButtonGroup::Start_Game);
    connect(ui->play_card_button_, &MyPushButton::clicked, this, &ButtonGroup::Play_Hand);
    connect(ui->play_card_button_1 ,&MyPushButton::clicked, this, &ButtonGroup::Play_Hand);
    connect(ui->pass_button_, &MyPushButton::clicked, this, &ButtonGroup::Pass);
    connect(ui->give_up_button_, &MyPushButton::clicked, this, [=](){emit Bet_Ponit(0);});
    connect(ui->one_score_button_, &MyPushButton::clicked, this, [=](){emit Bet_Ponit(1);});
    connect(ui->two_scores_button_, &MyPushButton::clicked, this, [=](){emit Bet_Ponit(2);});
    connect(ui->three_scores_button_, &MyPushButton::clicked, this, [=](){emit Bet_Ponit(3);});

}

void ButtonGroup::Select_Panel(const Panel &type)
{
    ui->stackedWidget->setCurrentIndex(type);
}
